package org.luxor.commons.storage.config;

import java.util.Arrays;

/**
 * 缩略图配置
 *
 * @author Mr.yan @date 2019/12/15
 */
public class ThumbImageConfig {
    final String[] DEFAULT_TYPE = {"jpg", "jpeg", "png", "gif", "bmp", "wbmp"};
    final Integer DEFAULT_WIDTH = 150;
    final Integer DEFAULT_HEIGHT = 150;

    /**
     * 支持缩略图的类型，比如：{ "jpg", "jpeg", "png", "gif", "bmp", "wbmp" }
     */
    private String[] type;
    /**
     * 宽度(单位 px)
     */
    private Integer width;
    /**
     * 高度(单位 px)
     */
    private Integer height;

    public ThumbImageConfig() {
        this.type = DEFAULT_TYPE;
        this.width = DEFAULT_WIDTH;
        this.height = DEFAULT_HEIGHT;
    }

    /**
     * 是否是支持的图片文件
     *
     * @param imageSuffix 图片文件后缀
     * @return
     */
    public boolean isSupportImage(String imageSuffix) {
        return Arrays.asList(this.getType()).contains(imageSuffix.toLowerCase());
    }

    public String[] getType() {
        return type;
    }

    public void setType(String[] type) {
        this.type = type;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }
}
